<span class="layui-breadcrumb">
    <a href="javascript:void(0)">当前位置:</a>
    <a href="javascript:void(0)">行方系统菜单 > </a>
     <a href="javascript:void(0)">系统管理 > </a>
    <a href="javascript:void(0)"><cite>参数管理</cite> </a>
</span>
<@shiro.hasPermission name="leioxingtianjia">
<div class="layui-form-item layui-form-item-top">
    <button class="layui-btn-tan" id="addType">
        <i class="layui-icon">&#xe608;</i> 添加
    </button>
</div>
</@shiro.hasPermission>
<form class="layui-form" action="${basePath}/system/dict/getDictlistPage" method="post" type="0" name="dictForm" id="dictForm">
<@shiro.hasPermission name="leixingchaxun">
    <div class="searchbox" id="searchbox">
        <input type="text" name="keywords" lay-verify="title" autocomplete="off" placeholder="请输入关键字" class="layui-input">
        <input type="button" value="查询" onclick="searchs();" class="layui-btn layui-btn-red"/>
    </div>
</@shiro.hasPermission>
    <div class="levTable">
        <table id="simple-table" class="table table-striped table-bordered table-hover" >
            <thead>
            <tr>
                <th style="width:50px;">序号</th>
                <th>申请类型</th>
                <th>类型名称</th>
                <th>类型编码</th>
                <th>企业编码</th>
                <th style="width: 100px;">操作</th>
            </tr>
            </thead>
            <tbody>
            <#list dictList?if_exists as var>
                <tr>
                    <td style="width: 30px;">${var_index+1}</td>
                    <td>${var.typeName}</td>
                    <td>${var.codeName}</td>
                    <td>${var.code}</td>
                    <td>${var.comCode}</td>
                    <td >
                    <@shiro.hasPermission name="leixingxiugai">
                        <a class="layui-icon" onclick="editDict('${var.dictId}','${var.comCode}');" title="修改">&#xe642;</a>
                    </@shiro.hasPermission>
                    <@shiro.hasPermission name="leixingshanchu">
                        <a class="layui-icon" onclick="deleteDict('${var.dictId}','${var.comCode}');" title="删除">&#xe640;</a>
                    </@shiro.hasPermission>
                    </td>
                </tr>
            </#list>
            </tbody>
        </table>
    </div>
    <#include "/common/page.html" />
</form>

<script type="text/javascript">
    var rooturl  = "${basePath}/sysuser/dict/getDictlistPage";
    //添加
    $("#addType").click(function(){
        var _url = $("form:eq(0)").attr("action");
        layer.open({
            type: 2,
            title : '添加类型',
            content: "${basePath}sysuser/dict/toDictEdit",
            area: [ '450px', '440px'],
            btn: ['确定', '取消'],
            yes : function(index, layero) {
                var iframeWin = window[layero.find('iframe')[0]['name']];
                    iframeWin.save();
            },
            no : function(index) {
                //layer.close(index);
            },
            end : function() {
//                setTimeout("self.location.reload()", 100);
                reLoadPage(rooturl);
            }
        });
    });
    //检索
    function searchs() {
        _GLOBE_DATA("reLoadPageParam")(_GLOBE_DATA("createURL")(rooturl,"searchbox"));
    }
    // 修改
    function editDict(Id,comCode) {
        if(comCode == ""){
                if("${Session['sessionUser'].comUserCode}"=="admin"){
                    var _url = $("form:eq(0)").attr("action");
                layer.open({
                    type : 2,//此处以iframe举例
                    title : '修改参数',
                    area : [ '450px', '440px' ],
                    maxmin : true,
                    content : '${basePath}sysuser/dict/toDictEdit?dictId='+Id,
                    btn : [ '保存', '关闭' ],
                    yes : function(index, layero) {
                        var iframeWin = window[layero.find('iframe')[0]['name']];
                        iframeWin.save();
                    },
                    no : function(index) {
                        //	layer.close(index);
                    },
                    end : function() {
                        reLoadPage(rooturl);
                    }
                });
            }else {
                    layer.alert("基本属性不允许修改");
                    return;
                }
        }else {
            var _url = $("form:eq(0)").attr("action");
            layer.open({
                type : 2,//此处以iframe举例
                title : '修改参数',
                area : [ '450px', '440px' ],
                maxmin : true,
                content : '${basePath}sysuser/dict/toDictEdit?dictId='+Id,
                btn : [ '保存', '关闭' ],
                yes : function(index, layero) {
                    var iframeWin = window[layero.find('iframe')[0]['name']];
                    iframeWin.save();
                },
                no : function(index) {
                    //	layer.close(index);
                },
                end : function() {
                    reLoadPage(rooturl);
                }
            });
        }
    }
    //删除
    function deleteDict(id,comCode){
        if(comCode == ""){
            if("${Session['sessionUser'].comUserCode}"=="admin"){
                layer.confirm('确认要删除吗？', {
                    btn: ['确定', '取消']
                }, function(index, layero){
                    $.ajax({
                        url : '${basePath}sysuser/dict/deleteDict',
                        data : {
                            "dictId": id
                        },
                        type : "POST",
                        success : function(data) {
                            if (data.status == 'success') {
                                layer.alert(data.msg,function(index){
                                    var index1 = parent.layer.getFrameIndex(window.name); //获取窗口索引
                                    parent.layer.close(index1);
                                    parent.layer.close(index);
                                    reLoadPage(rooturl);
                                });
                            } else {
                                layer.alert(data.msg);
                            }
                        }
                    });
                });
            }else {
                layer.alert("基本属性不允许修改");
                return;
            }
        }else {
            layer.confirm('确认要删除吗？', {
                btn: ['确定', '取消']
            }, function(index, layero){
                $.ajax({
                    url : '${basePath}sysuser/dict/deleteDict',
                    data : {
                        "dictId": id
                    },
                    type : "POST",
                    success : function(data) {
                        if (data.status == 'success') {
                            layer.alert(data.msg,function(index){
                                var index1 = parent.layer.getFrameIndex(window.name); //获取窗口索引
                                parent.layer.close(index1);
                                parent.layer.close(index);
                                reLoadPage(rooturl);
                            });
                        } else {
                            layer.alert(data.msg);
                        }
                    }
                });
            });
        }

    }

</script>
</html>
